package com.egao.orderB.controller2;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.*;
import com.egao.common.core.annotation.OperLog;
import com.egao.orderB.entity.BillProcess;
import com.egao.orderB.service.BillProcessService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.ui.Model;


/**
 *
 * 订单流程状态
 * @author : Doman
 * @date : 2020-06-17 09:37:30
 * @version ：1.0
 */

//@Api(tags = "订单流程状态")
//@RestController
//@RequestMapping("/api/billProcess2")
public class BillProcessController extends BaseController {

	@Autowired
	private BillProcessService billProcessService;

	/**
	 * 分页查询列表
	 */
    @PreAuthorize("hasAuthority('orderB:billProcess:list')")
	@OperLog(value = "订单流程状态", desc = "分页查询")
    @ApiOperation("分页查询订单流程状态")
    @ApiPageParam
	@PostMapping("/page")
    public JsonResult list(PageResult2<T> page, BillProcess billProcess) throws Exception{
        return billProcessService.list(page, billProcess, getLoginUser());
    }

    /**
     * 查询全部订单流程状态
     */
    @PreAuthorize("hasAuthority('orderB:billProcess:list')")
    @OperLog(value = "订单流程状态", desc = "查询全部")
    @ApiOperation("查询全部订单流程状态")

    @PostMapping("/list")
    public JsonResult list(BillProcess billProcess){
        return billProcessService.list(billProcess, getLoginUser());
    }

    /**
     * 根据id查询订单流程状态
     */
    @PreAuthorize("hasAuthority('orderB:billProcess:list')")
    @OperLog(value = "订单流程状态", desc = "根据id查询")
    @ApiOperation("根据id查询订单流程状态")

    @PostMapping("/get")
    public JsonResult get(BillProcess billProcess) {
        return JsonResult.ok().setData(billProcessService.getById(billProcess));
		// 使用关联查询
        //PageParam<billProcess> pageParam = new PageParam<>();
		//pageParam.put("id", id);
        //List<billProcess> records = billProcessService.listAll(pageParam.getNoPageParam());
        //return JsonResult.ok().setData(pageParam.getOne(records));
    }


    /**
     * 添加订单流程状态
     */
    @PreAuthorize("hasAuthority('orderB:billProcess:save')")
    @OperLog(value = "订单流程状态", desc = "添加", param = false, result = true)
    @ApiOperation("添加订单流程状态")

    @PostMapping("/save")
    public JsonResult save(Model model, BillProcess billProcess) {
        return billProcessService.save(billProcess, getLoginUser());
    }

    /**
     * 修改订单流程状态
     */
    @PreAuthorize("hasAuthority('orderB:billProcess:update')")
    @OperLog(value = "订单流程状态", desc = "修改", param = false, result = true)
    @ApiOperation("修改订单流程状态")

    @PostMapping("/update")
    public JsonResult update(Model model, BillProcess billProcess) {
        return billProcessService.update(billProcess, getLoginUser());
    }

    /**
     * 删除订单流程状态
     */
    @PreAuthorize("hasAuthority('orderB:billProcess:remove')")
    @OperLog(value = "订单流程状态", desc = "删除", result = true)
    @ApiOperation("删除订单流程状态")

    @PostMapping("/remove")
    public JsonResult remove(BillProcess billProcess ) {
        return billProcessService.remove(billProcess, getLoginUser());
    }

    /**
     * 批量添加订单流程状态
     */
    /**@RequiresPermissions("orderB:billProcess:save")
    @OperLog(value = "订单流程状态", desc = "批量添加", param = false, result = true)

    @PostMapping("/saveBatch")
    public JsonResult saveBatch(@RequestBody List<BillProcess> list) {
        if (billProcessService.saveBatch(list)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }*/

    /**
     * 批量修改订单流程状态
     */
    /**@RequiresPermissions("orderB:billProcess:update")
    @OperLog(value = "订单流程状态", desc = "批量修改", result = true)

    @PostMapping("/updateBatch")
    public JsonResult updateBatch(@RequestBody BatchParam<BillProcess> batchParam) {
        if (batchParam.update(billProcessService, "")) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }*/

    /**
     * 批量删除订单流程状态
     */
    /**@RequiresPermissions("orderB:billProcess:remove")
    @OperLog(value = "订单流程状态", desc = "批量删除", result = true)

    @PostMapping("/removeBatch")
    public JsonResult removeBatch(@RequestBody List<Integer> ids) {
        if (billProcessService.removeByIds(ids)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }*/

}
